package com.ronx.scs.validator;

import com.ronx.scs.model.User;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class UserValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return aClass.equals(User.class);
    }

    @Override
    public void validate(Object o, Errors errors) {
//        User user = (User) o;
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "surname", "surname", "required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "name", "required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastname", "lastname", "required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "passportNumber", "passportNumber", "required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "personalNumber", "personalNumber", "required");
    }
}

